package com.atguigu.pojo;

import java.util.List;

public class Page <T>{
    public static final Integer PAGE_SIZE=4;//一般常量是要大写的
    private Integer pageNo;//当前页码
    private Integer pageTotal;//总页码
    private Integer pagesize=PAGE_SIZE;//当前页显示数量



    private Integer pageTotalCount;// 总记录数
    private List<T> items;//当前页的数据 //T 是为了使得分页类可以用来盛任何对象,例如用户,图书
    private String url;//分页的前半部分地址,这跟业务相关,跟分页行为无关
    //这个参数,被用在"跳转页地址url生成"时,action是page时,采用得到;也就是有分页需求时才用得到

    public Page() {
    }

    public Page(Integer pageNo, Integer pageTotal, Integer pagesize, Integer pageTotalCount, List<T> items,String url) {
        this.pageNo = pageNo;
        this.pageTotal = pageTotal;
        this.pagesize = pagesize;
        this.pageTotalCount = pageTotalCount;
        this.items = items;
        this.url = url;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        if(pageNo<1){//防止用户输入量太大
            pageNo=1;
        }else if(pageNo>pageTotal){
            pageNo=pageTotal;
        }
        this.pageNo = pageNo;
    }

    public Integer getPageTotal() {
        return pageTotal;
    }

    public void setPageTotal(Integer pageTotal) {
        this.pageTotal = pageTotal;
    }

    public Integer getPagesize() {
        return pagesize;
    }

    public void setPagesize(Integer pagesize) {
        this.pagesize = pagesize;
    }

    public Integer getPageTotalCount() {
        return pageTotalCount;
    }

    public void setPageTotalCount(Integer pageTotalCount) {
        this.pageTotalCount = pageTotalCount;
    }

    public List<T> getItems() {
        return items;
    }

    public void setItems(List<T> items) {
        this.items = items;
    }
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public String toString() {
        return "Page{" +
                "pageNo=" + pageNo +
                ", pageTotal=" + pageTotal +
                ", pagesize=" + pagesize +
                ", pageTotalCount=" + pageTotalCount +
                ", items=" + items +
                ", url='" + url + '\'' +
                '}';
    }
}
